﻿namespace ConsoleApp1
{

    using System;

    // 定义闹钟类 
    class AlarmClock
    {
        public event EventHandler Tick;
        public event EventHandler Alarm;

        public void TickTock()
        {
            Console.WriteLine("闹钟正在走时...");
            Tick?.Invoke(this, EventArgs.Empty);
        }

        public void Ring()
        {
            Console.WriteLine("闹钟响铃！");
            Alarm?.Invoke(this, EventArgs.Empty);
        }
    }

    class Program
    {
        static void Main()
        {
            AlarmClock clock = new AlarmClock();

            clock.Tick += (sender, e) =>
            {
                Console.WriteLine("滴答事件触发");
            };

            clock.Alarm += (sender, e) =>
            {
                Console.WriteLine("响铃事件触发");
            };

            clock.TickTock();
            clock.Ring();

            Console.ReadLine();
        }
    }
}
